#ifndef __GLF_PLATFORM_H_INCLUDED__
#define __GLF_PLATFORM_H_INCLUDED__

#if __APPLE__
#include <TargetConditionals.h>
#endif

#if PLATFORM_NUL

#	define GLF_PLATFORM nul
#	define GLF_PLATFORM_NUL 1

#elif defined(RVL_OS)

#	define GLF_PLATFORM rvl
#	define GLF_PLATFORM_RVL 1

#elif SN_TARGET_PS3

#	define GLF_PLATFORM ps3
#	define GLF_PLATFORM_PS3 1

#elif SN_TARGET_PSP2

#	define GLF_PLATFORM psp2
#	define GLF_PLATFORM_PSP2 1

#elif defined(NN_PLATFORM_CTR)

#	define GLF_PLATFORM ctr
#	define GLF_PLATFORM_CTR 1

#elif defined(PLATFORM_PLAYBOOK)

#	define GLF_PLATFORM playbook
#	define GLF_PLATFORM_PLAYBOOK 1

#elif PLATFORM_NACL

#	define GLF_PLATFORM nacl
#	define GLF_PLATFORM_NACL 1

#elif PLATFORM_X11

#	define GLF_PLATFORM x11
#	define GLF_PLATFORM_X11 1

#elif PLATFORM_POSIX

#	define GLF_PLATFORM posix
#	define GLF_PLATFORM_POSIX 1

#elif PLATFORM_SDL

#	define GLF_PLATFORM sdl
#	define GLF_PLATFORM_SDL 1

#elif PLATFORM_LINUX_X11

#	define GLF_PLATFORM x11
#	define GLF_PLATFORM_X11 1

#elif PLATFORM_SYMBIAN

#	define GLF_PLATFORM symbian
#	define GLF_PLATFORM_SYMBIAN 1

#elif PLATFORM_PALMPRE

#	define GLF_PLATFORM palmpre
#	define GLF_PLATFORM_PALMPRE 1

#elif PLATFORM_NGI

#	define GLF_PLATFORM ngi
#	define GLF_PLATFORM_NGI 1

#elif defined(PLATFORM_IPHONE)

#	define GLF_PLATFORM iphone
#	define GLF_PLATFORM_IPHONE 1

#elif defined(SHP)

#	define GLF_PLATFORM osp
#	define GLF_PLATFORM_OSP

#elif defined(OS_WP8)

#	define GLF_PLATFORM wp8
#	define GLF_PLATFORM_WP8 1

#elif defined(_WIN32) || defined(_MSC_VER) || defined(WIN32)

#	define GLF_PLATFORM win32
#	define GLF_PLATFORM_WIN32 1

#elif defined(__ANDROID__) || defined(ANDROID)

#	define GLF_PLATFORM android
#	define GLF_PLATFORM_ANDROID 1

#else
// if we reached here, we don't really know which platform we're using. It
// could simply indicate the absence of PLATFORM_XXX define.
// So we check a few known compiler's defines to fall back to the correct
// platforms.
#	if linux || __linux || __linux__
#		define GLF_PLATFORM posix
#		define GLF_PLATFORM_POSIX 1
#	else
#		define GLF_PLATFORM macosx
#		define GLF_PLATFORM_MACOSX 1
#	endif
#endif

#if GLF_PLATFORM_WIN32

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0502
#endif

#ifndef WINVER
#define WINVER 0x0502
#endif

#endif

#define GLF_PLATFORM_STR GLF_TOSTRING(GLF_PLATFORM)

#define GLF_PLATFORM_HEADER(path)				GLF_PLATFORM_HEADER1(path, GLF_PLATFORM)
#define GLF_PLATFORM_HEADER1(path, platform)	GLF_PLATFORM_HEADER2(path, platform)
#define GLF_PLATFORM_HEADER2(path, platform)	GLF_PLATFORM_HEADER3(path, platform)
#define GLF_PLATFORM_HEADER3(path, platform)	<path##_##platform##_.h>

#if defined(SN_TARGET_PSP2) // Compilation fix with distributed build
	#include <glf/config/platform_psp2_.h>
#else
	#include GLF_PLATFORM_HEADER(glf/config/platform)
#endif

#ifndef GLF_API_SOCKET
	#define GLF_API_SOCKET nul
#endif

#ifndef GLF_API_INPUT
	#define GLF_API_INPUT nul
#endif

#ifndef GLF_API_APP
	#define GLF_API_APP nul
#endif

#ifndef GLF_API_CONFIG
	#define GLF_API_CONFIG nul
#endif

#if GLF_BIG_ENDIAN
	#define GLF_LITTLE_ENDIAN 0
#endif

#if GLF_LITTLE_ENDIAN
	#define GLF_BIG_ENDIAN 0
	#define GLF_ENDIAN little
#else
	#define GLF_ENDIAN big
#endif

#define GLF_ENDIAN_STR GLF_TOSTRING(GLF_ENDIAN)

#endif

